const _function = require("../../utils/functionData.js")
Page({
  data: {
    isRefreshing: false,
    isLoading: false,
    hasMore: true,
    page: 1,
    activityList: [{
      id: 1,
      name: "AI创新工作坊",
      description: "深度学习实践与模型优化专题研讨会，提供GPU算力支持",
      participants: 89
    }]
  },
  onLoad(options) {
    this.getStudentActivityList()
  },
  getStudentActivityList() {
    console.log('获取社团详情');
    const prams = {
      studentId: getApp().globalData.userInfo.userId
    }
    _function.getStudentActivityList(prams, this.getStudentActivityListBack, this)
  },
  getStudentActivityListBack(res) {
    let dataAll = res.data
    if (dataAll.code == 200) {
      this.setData({
            activityList:dataAll.rows
      })
      console.log('消息列表', dataAll.data);
    }
  },
  onPullDownRefresh() {
    this.setData({ isRefreshing: true });
    setTimeout(() => {
      this.setData({ 
        activityList: [...newData],
        isRefreshing: false,
        page: 1
      });
      wx.stopPullDownRefresh();
    }, 1500);
  },

  loadMore() {
    if (!this.data.hasMore || this.data.isLoading) return;
    
    this.setData({ isLoading: true });
    setTimeout(() => {
      this.setData({
        activityList: [...this.data.activityList, ...newData],
        page: this.data.page + 1,
        isLoading: false,
        hasMore: this.data.page < 3
      });
    }, 1000);
  }
});